<!doctype html>
<html>

	<head>
		<meta http-equiv="content-type" content="text/html; charset=UTF-8">
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
		<!-- Apple devices fullscreen -->
		<meta name="apple-mobile-web-app-capable" content="yes">
		<!-- Apple devices fullscreen -->
		<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
		<link href="../css/main.css?v=12u234y" rel="stylesheet" type="text/css">
		<link href="../css/page.css" rel="stylesheet" type="text/css">
		<link href="../font/css/font-awesome.min.css" rel="stylesheet" />
		<!--[if IE 7]>
  <link rel="stylesheet" href="../font/css/font-awesome-ie7.min.css">
<![endif]-->
		<link href="../js/jquery-ui/jquery-ui.min.css" rel="stylesheet" type="text/css" />
		<link href="../js/perfect-scrollbar.min.css" rel="stylesheet" type="text/css" />
		<style type="text/css">
			html,
			body {
				overflow: visible;
			}
		</style>
		<script type="text/javascript" src="../js/jquery.js"></script>
		<script type="text/javascript" src="../js/jquery-ui/jquery-ui.min.js"></script>
		<script type="text/javascript" src="../js/layer/layer.js"></script>
		<!-- 弹窗js 参考文档 http://layer.layui.com/-->
		<script type="text/javascript" src="../js/admin.js"></script>
		<script type="text/javascript" src="../js/flexigrid.js"></script>
		<script type="text/javascript" src="../js/jquery.validation.min.js"></script>
		<script type="text/javascript" src="../js/perfect-scrollbar.min.js"></script>
		<script type="text/javascript" src="../js/jquery.mousewheel.js"></script>
		<script src="../js/myFormValidate.js"></script>
		<script src="../js/myAjax2.js"></script>
		<script src="../js/global.js"></script>
		<script type="text/javascript">
			function delfunc(obj) {
				layer.confirm('确认删除？', {
					btn: ['确定', '取消'] //按钮
				}, function() {
					$.ajax({
						type: 'post',
						url: $(obj).attr('data-url'),
						data: {
							act: 'del',
							del_id: $(obj).attr('data-id')
						},
						dataType: 'json',
						success: function(data) {
							if(data == 1) {
								layer.msg('操作成功', {
									icon: 1
								});
								$(obj).parent().parent().parent().remove();
							} else {
								layer.msg(data, {
									icon: 2,
									time: 2000
								});
							}
						}
					})
				}, function(index) {
					layer.close(index);
					return false; // 取消
				});
			}

			function delAll(obj, name) {
				var a = [];
				$('input[name*=' + name + ']').each(function(i, o) {
					if($(o).is(':checked')) {
						a.push($(o).val());
					}
				})
				if(a.length == 0) {
					layer.alert('请选择删除项', {
						icon: 2
					});
					return;
				}
				layer.confirm('确认删除？', {
					btn: ['确定', '取消']
				}, function() {
					$.ajax({
						type: 'get',
						url: $(obj).attr('data-url'),
						data: {
							act: 'del',
							del_id: a
						},
						dataType: 'json',
						success: function(data) {
							if(data == 1) {
								layer.msg('操作成功', {
									icon: 1
								});
								$('input[name*=' + name + ']').each(function(i, o) {
									if($(o).is(':checked')) {
										$(o).parent().parent().remove();
									}
								})
							} else {
								layer.msg(data, {
									icon: 2,
									time: 2000
								});
							}
							layer.closeAll();
						}
					})
				}, function(index) {
					layer.close(index);
					return false; // 取消
				});
			}

			//表格列表全选反选
			$(document).ready(function() {
				$('.hDivBox .sign').click(function() {
					var sign = $('#flexigrid > table>tbody>tr');
					if($(this).parent().hasClass('trSelected')) {
						sign.each(function() {
							$(this).removeClass('trSelected');
						});
						$(this).parent().removeClass('trSelected');
					} else {
						sign.each(function() {
							$(this).addClass('trSelected');
						});
						$(this).parent().addClass('trSelected');
					}
				})
			});

			//获取选中项
			function getSelected() {
				var selectobj = $('.trSelected');
				var selectval = [];
				if(selectobj.length > 0) {
					selectobj.each(function() {
						selectval.push($(this).attr('data-id'));
					});
				}
				return selectval;
			}
		</script>
	</head>

	<body style="background-color: #FFF; overflow: auto;">
		<div id="append_parent"></div>
		<div id="ajaxwaitid"></div>
		<div class="page">
			<div class="fixed-bar">
				<div class="item-title">
					<a class="back" href="javascript:history.back();" title="返回列表"><i class="fa fa-arrow-circle-o-left"></i></a>
					<div class="subject">
						<h3>商品分类 - 添加修改分类</h3>
						<h5>添加或编辑商品分类</h5>
					</div>
				</div>
			</div>
			<div class="explanation" id="explanation">
				<div class="title" id="checkZoom"><i class="fa fa-lightbulb-o"></i>
					<h4 title="提示相关设置操作时应注意的要点">操作提示</h4>
					<span id="explanationZoom" title="收起提示"></span>
				</div>
				<ul>
					<li>商品分类最多分为三级</li>
					<li>商品分类可以关联商品类型</li>
					<li>商品类型关联商品规格商品属性。</li>
				</ul>
			</div>
			<form action="/index.php/admin/Goods/addEditCategory.html" method="post" class="form-horizontal" id="category_form">
				<div class="ncap-form-default">
					<dl class="row">
						<dt class="tit">
          <label><em>*</em>分类名称</label>
        </dt>
						<dd class="opt">
							<input type="text" placeholder="名称" class="input-txt" name="name" value="">
							<span class="err" id="err_name" style="color:#F00; display:none;"></span>
							<p class="notic"></p>
						</dd>
					</dl>
					<dl class="row">
						<dt class="tit">
          <label><em>*</em>手机分类名称</label>
        </dt>
						<dd class="opt">
							<input type="text" placeholder="手机分类名称" class="input-txt" name="mobile_name" value="">
							<span class="err" id="err_mobile_name" style="color:#F00; display:none;"></span>
							<p class="notic"></p>
						</dd>
					</dl>
					<dl class="row">
						<dt class="tit" colspan="2">
          <label>上级分类</label>
        </dt>
						<dd class="opt">
							<div id="gcategory">
								<select name="parent_id_1" id="parent_id_1" onchange="get_category(this.value,'parent_id_2','0');" class="class-select valid">
									<option value="0">顶级分类</option>

									<option value="1">手机 、 数码 、 通信</option>

									<option value="7">计生情趣</option>

									<option value="14">旅游出行</option>

									<option value="21">母婴</option>

									<option value="24">非人工复古风格</option>

									<option value="25">家用电器</option>

									<option value="26">手机数码</option>

									<option value="27">电脑办公</option>

									<option value="28">家居家具</option>

									<option value="29">男装女装</option>

									<option value="30">美妆个护宠物</option>

									<option value="31">男鞋户外</option>

									<option value="32">汽车 / 汽车用品</option>

									<option value="33">母婴 / 玩具乐器</option>

									<option value="34">食品酒类</option>

									<option value="35">礼品鲜花</option>

									<option value="36">医药保健</option>

									<option value="37">图书音像</option>

								</select>
								<select name="parent_id_2" id="parent_id_2" class="class-select valid">
									<option value="0">请选择商品分类</option>
								</select>
							</div>
							<p class="notic">最多成为第三级,如果设置为第二级, 只选择第一级即可</p>
						</dd>
					</dl>
					<dl class="row">
						<dt class="tit">
          <label><em>*</em>导航显示</label>
        </dt>
						<dd class="opt">
							<div class="onoff">
								<label for="goods_category1" class="cb-enable ">是</label>
								<label for="goods_category0" class="cb-disable selected">否</label>
								<input id="goods_category1" name="is_show" value="1" type="radio">
								<input id="goods_category0" name="is_show" value="0" type="radio" checked="checked">
							</div>
							<p class="notic">是否在导航栏显示</p>
						</dd>
					</dl>

					<dl class="row">
						<dt class="tit" colspan="2">
          <label>分类分组</label>
        </dt>
						<dd class="opt">
							<div>
								<select name="cat_group" id="cat_group" class="form-control">
									<option value="0">0</option>
									<option value='1'>1</option>"
									<option value='2'>2</option>"
									<option value='3'>3</option>"
									<option value='4'>4</option>"
									<option value='5'>5</option>"
									<option value='6'>6</option>"
									<option value='7'>7</option>"
									<option value='8'>8</option>"
									<option value='9'>9</option>"
									<option value='10'>10</option>"
									<option value='11'>11</option>"
									<option value='12'>12</option>"
									<option value='13'>13</option>"
									<option value='14'>14</option>"
									<option value='15'>15</option>"
									<option value='16'>16</option>"
									<option value='17'>17</option>"
									<option value='18'>18</option>"
									<option value='19'>19</option>"
									<option value='20'>20</option>"
								</select>
							</div>
							<p class="notic">有时候左侧菜单栏同一行显示多个分类, 所以给他们一个分组</p>
						</dd>
					</dl>

					<dl class="row">
						<dt class="tit">
          <label>分类展示图片</label>
        </dt>
						<dd class="opt">
							<div class="input-file-show">
								<span class="show">
                <a id="img_a" target="_blank" class="nyroModal" rel="gal" href="">
                  <i id="img_i" class="fa fa-picture-o" onmouseover="layer.tips('<img src=>',this,{tips: [1, '#fff']});" onmouseout="layer.closeAll();"></i>
                </a>
            </span>
								<span class="type-file-box">
                <input type="text" id="image" name="image" value="" class="type-file-text">
                <input type="button" name="button" id="button1" value="选择上传..." class="type-file-button">
                <input class="type-file-file" onClick="GetUploadify(1,'','category','img_call_back')" size="30" hidefocus="true" nc_type="change_site_logo" title="点击前方预览图可查看大图，点击按钮选择文件并提交表单后上传生效">
            </span>
							</div>
							<span class="err"></span>
							<p class="notic">请上传图片格式文件</p>
						</dd>
					</dl>
					<dl class="row">
						<dt class="tit">
          <label for="t_sort"><em>*</em>排序</label>
        </dt>
						<dd class="opt">
							<input type="text" class="t_mane" name="sort_order" id="t_sort" value="">
							<span class="err" style="color:#F00; display:none;" id="err_sort_order"></span>
							<p class="notic">根据排序进行由小到大排列显示。</p>
						</dd>
					</dl>
					<dl class="row">
						<dt class="tit">
          <label for="t_sort"><em>*</em>抽成比例</label>
        </dt>
						<dd class="opt">
							<input type="text" class="t_mane" name="commission" id="commission" value="" onpaste="this.value=this.value.replace(/[^\d.]/g,'')" onkeyup="this.value=this.value.replace(/[^\d.]/g,'')">%
							<span class="err" style="color:#F00; display:none;" id="err_commission"></span>
							<p class="notic">平台抽成商家的比例。</p>
						</dd>
					</dl>
					<dl class="row">
						<dt class="tit">
          <label>关联模型</label>
        </dt>
						<dd class="opt">
							<div>
								<select name="cat_id1" id="cat_id1" class="form-control" onchange="get_category(this.value,'cat_id2','0');spec_scroll(this);" style="width:250px;">
									<option value="0">所有分类</option>

									<option value="1">手机 、 数码 、 通信</option>

									<option value="7">计生情趣</option>

									<option value="14">旅游出行</option>

									<option value="21">母婴</option>

									<option value="24">非人工复古风格</option>

									<option value="25">家用电器</option>

									<option value="26">手机数码</option>

									<option value="27">电脑办公</option>

									<option value="28">家居家具</option>

									<option value="29">男装女装</option>

									<option value="30">美妆个护宠物</option>

									<option value="31">男鞋户外</option>

									<option value="32">汽车 / 汽车用品</option>

									<option value="33">母婴 / 玩具乐器</option>

									<option value="34">食品酒类</option>

									<option value="35">礼品鲜花</option>

									<option value="36">医药保健</option>

									<option value="37">图书音像</option>

								</select>
								<select name="cat_id2" id="cat_id2" class="form-control" onchange="get_category(this.value,'cat_id3','0');" style="width:250px;">
									<option value="0">请选择商品分类</option>
								</select>
								<select name="cat_id3" id="cat_id3" class="form-control" style="width:250px;">
									<option value="0">请选择商品分类</option>
								</select>
							</div>
							<div class="scrollbar-box ps-container ps-active-y">
								<div class="ncap-type-spec-list" id="ajax_brandList" style="height:160px;overflow: auto;">
									<dl>
										<dt style="display: block;" id="type_id_0">默认</dt>
										<dd>
										</dd>
									</dl>
									<dl>
										<dt style="display: block;" id="type_id_1">手机 、 数码 、 通信</dt>
										<dd>
											<label style="display: inline-block;" for="type_id_2">
                        <input type="radio" id="type_id_2" value="2"  class="brand_change_default_submit_value" name="type_id" >
                        手机                      </label>
											<label style="display: inline-block;" for="type_id_4">
                        <input type="radio" id="type_id_4" value="4"  class="brand_change_default_submit_value" name="type_id" >
                        相机                      </label>
										</dd>
									</dl>
									<dl>
										<dt style="display: block;" id="type_id_14">旅游出行</dt>
										<dd>
											<label style="display: inline-block;" for="type_id_3">
                        <input type="radio" id="type_id_3" value="3"  class="brand_change_default_submit_value" name="type_id" >
                        门票                      </label>
										</dd>
									</dl>
									<dl>
										<dt style="display: block;" id="type_id_21">母婴</dt>
										<dd>
											<label style="display: inline-block;" for="type_id_5">
                        <input type="radio" id="type_id_5" value="5"  class="brand_change_default_submit_value" name="type_id" >
                        奶粉                      </label>
										</dd>
									</dl>

								</div>
							</div>
						</dd>
					</dl>
					<div class="bot">
						<a id="submitBtn" class="ncap-btn-big ncap-btn-green" href="JavaScript:void(0);" onclick="ajax_submit_form('category_form','/index.php/admin/Goods/addEditCategory/is_ajax/1.html');">确认提交</a>
					</div>
				</div>
				<input type="hidden" name="id" value="">
			</form>
		</div>
		<script>
			/** 以下是编辑时默认选中某个商品分类*/
			$(document).ready(function() {});

			// 将品牌滚动条里面的 对应分类移动到 最上面
			//javascript:document.getElementById('category_id_3').scrollIntoView();
			var typeScroll = 0;

			function spec_scroll(o) {
				var id = $(o).val();
				//if(!$('#type_id_'+id).is('dt')){
				//return false;
				//} 	 
				$('#ajax_brandList').scrollTop(-typeScroll);
				var sp_top = $('#type_id_' + id).offset().top; // 标题自身往上的 top
				var div_top = $('#ajax_brandList').offset().top; // div 自身往上的top
				$('#ajax_brandList').scrollTop(sp_top - div_top); // div 移动
				typeScroll = sp_top - div_top;
			}

			function img_call_back(fileurl_tmp) {
				$("#image").val(fileurl_tmp);
				$("#img_a").attr('href', fileurl_tmp);
				$("#img_i").attr('onmouseover', "layer.tips('<img src=" + fileurl_tmp + ">',this,{tips: [1, '#fff']});");
			}
		</script>
	</body>

</html>